package com.tianyuan.dplrf.ui.activity;

import androidx.appcompat.widget.AppCompatTextView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.content.pm.ActivityInfo;
import android.os.Build;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;

import com.hjq.base.BaseAdapter;
import com.hjq.base.BaseDialog;
import com.hjq.widget.layout.WrapRecyclerView;
import com.tencent.mm.opensdk.modelmsg.SendMessageToWX;
import com.tianyuan.dplrf.R;
import com.tianyuan.dplrf.app.AppActivity;
import com.tianyuan.dplrf.other.DoubleClickHelper;
import com.tianyuan.dplrf.ui.adapter.NczdAdapter;
import com.tianyuan.dplrf.ui.bean.NczdBean;
import com.tianyuan.dplrf.ui.common.SpaceItemDecoration;
import com.tianyuan.dplrf.ui.popup.SharePop2;
import com.tianyuan.dplrf.wxapi.WeChatShareUtils;

import java.util.ArrayList;
import java.util.List;

public class NczdAct extends AppActivity implements View.OnClickListener, BaseAdapter.OnItemClickListener {
    private ImageView img_land_back;
    private TextView tv_title;
    private AppCompatTextView tv_onlinemall;
    private AppCompatTextView tv_wdnc;
    private AppCompatTextView tv_share;
    private AppCompatTextView tv_mine;
    private WrapRecyclerView recycle_content;

    private List<NczdBean> zdList;
    private NczdAdapter mAdapter;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_nczd;
    }

    @Override
    protected void initView() {

        img_land_back = findViewById(R.id.img_land_back);
        tv_title = findViewById(R.id.tv_title);
        tv_onlinemall = findViewById(R.id.tv_onlinemall);
        tv_wdnc = findViewById(R.id.tv_wdnc);
        tv_share = findViewById(R.id.tv_share);
        tv_mine = findViewById(R.id.tv_mine);
        recycle_content = findViewById(R.id.recycle_content);
        img_land_back.setOnClickListener(this);
        tv_onlinemall.setOnClickListener(this);
        tv_wdnc.setOnClickListener(this);
        tv_share.setOnClickListener(this);
        tv_mine.setOnClickListener(this);


    }

    @Override
    protected void initData() {

        textdrawableSetting(tv_mine, R.drawable.ic_user,28, Gravity.TOP);
        textdrawableSetting(tv_onlinemall, R.drawable.ic_briefcase_1,28, Gravity.TOP);
        textdrawableSetting(tv_share, R.drawable.ic_share,28, Gravity.TOP);
        textdrawableSetting(tv_wdnc, R.drawable.ic_sunrise,28, Gravity.TOP);

        zdList = new ArrayList<>();
        for (int a = 0; a < 5; a++) {
            NczdBean bean = new NczdBean();
            bean.setId(R.drawable.img_sysun);
            bean.setNcName("城市农场" + String.format("%02d", a + 1));
            bean.setDescrip("......");
            zdList.add(bean);
        }
        mAdapter = new NczdAdapter(this, zdList);
        mAdapter.setOnItemClickListener(this);
        LinearLayoutManager layoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);//true 倒转显示
        recycle_content.setLayoutManager(layoutManager);
        recycle_content.addItemDecoration(new SpaceItemDecoration(10));
        recycle_content.setAdapter(mAdapter);


    }

    @Override
    public void onItemClick(RecyclerView recyclerView, View itemView, int position) {
        if (DoubleClickHelper.isOnDoubleClick()){
            Log.d(getTag(), "onItemClick: double" );
        }else {
            Log.d(getTag(), "onItemClick: " + position);
            startActivity(ChoosezdpageActivity.class);
        }
    }

    @Override
    public void onClick(View view) {
        if (DoubleClickHelper.isOnDoubleClick()){
            Log.e(getTag(), "onClick: doubleclick");
            return;
        }
        switch (view.getId()) {
            case R.id.img_land_back:
                finish();
                break;
            case R.id.tv_onlinemall:
                break;
            case R.id.tv_wdnc:
                startActivity(MinencAct.class);
                break;
            case R.id.tv_share:
                SharePop2.Builder build = new SharePop2.Builder(this);

                build.create().setFullScreen().show();

//                WeChatShareUtils.getInstance(getApplicationContext()).shareText("你好 ", SendMessageToWX.Req.WXSceneSession);
                break;
            case R.id.tv_mine:
//                WeChatShareUtils.getInstance(getApplicationContext()).shareText("你好 ", SendMessageToWX.Req.WXSceneTimeline);
                break;
        }
    }


}